package com.any.sckill.distributed.zookeeper;

import java.util.concurrent.TimeUnit;

import org.apache.curator.framework.recipes.locks.InterProcessMutex;

public interface CuratorProxy {
	
	/**
	 * 创建分布式锁
	 * @return
	 */
	InterProcessMutex getMutex();
	
	/**
	 * 创建zk node，并初始化内容
	 * @param nodeName
	 * @param content
	 * @return
	 */
	boolean createNode(String nodeName, byte[] content);
	
	boolean setData(String nodeName, byte[] content);
	
	byte[] getData(String nodeName);
	
	String getMutexNodeName();
	
	/**
	 * 删除zk node By nodeName
	 * @param nodeName
	 * @return
	 */
	boolean deleteNode(String nodeName);
	
	/**
	 * 加锁
	 * @param time
	 * @param unit
	 * @return
	 */
	boolean acquire(long time, TimeUnit unit);
	
	/**
	 * 释放锁
	 */
	void release();

}
